
const isArrayContains =(array, element) => {
  for(let i=0;i<array.length;i++) {
    let t = array[i];
    if(t===element){
      return true;
    }
  }
  return false;
}

const wordsContains =(array, word) => {
  var result = [];
  if (word==null || word=='') {
    return array;
  }
  for(let i=0;i<array.length;i++){
    let t = array[i];
    if(startWith(t, word)) {
      result.push(t);
    }
  }
  return result;
}

function startWith(str, word) {
  if(word.length>str.length){
    return false;
  } else {
    for(let i=0;i<word.length;i++) {
      let ch = word.charAt(i);
      if (str.charAt(i)!==ch) {
        return false;
      }
    }
  }
  return true;
}

module.exports = {
  isArrayContains: isArrayContains,
  wordsContains: wordsContains
}